package com.linxs.me.intefaces.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.kissme.core.orm.Page;
import com.linxs.me.application.blog.BlogService;
import com.linxs.me.domain.blog.Blog;
import com.linxs.me.intefaces.utils.WebUtils;

/**
 * 
 * @author Linxs
 *
 */
@Controller
public class LinxsController {
	
	@Autowired
	private BlogService blogService;

	@RequestMapping(value = {"/", "/linxs"}, method = RequestMethod.GET)
	public String linxs(Model model) {
		model.addAttribute("page", blogService.queryPage(new Page<Blog>().setPageNo(1).setPageSize(10)));
		return "linxs";
	}
	
	@RequestMapping(value = "/linxs/get/{pageNo}", method = RequestMethod.GET)
	public void linxs(HttpServletResponse response, @PathVariable("pageNo")int pageNo) throws Exception {
		List<Blog> result =  blogService.queryPage(new Page<Blog>().setPageNo(pageNo).setPageSize(10)).getResult();
		WebUtils.asynchronizationResponse(response, result);
	}
	
	
	
}
